from datetime import datetime
from sqlalchemy import Column, String, Integer, Text, Date, DateTime
from sqlalchemy.ext.declarative import declarative_base

# 创建对象的基类
Model = declarative_base()


class Base:
    create_at = Column(DateTime(), default=datetime.now)
    update_at = Column(DateTime(), default=datetime.now, onupdate=datetime.now)


# 公司模型
class Company(Base, Model):
    # 表名
    __tablename__ = 'lagou_company'
    # 表结构
    id = Column(Integer(), primary_key=True)
    name = Column(String(10))
    total_name = Column(String(50))
    type = Column(String(20))
    size = Column(String(20))
    finance = Column(String(20))
    description = Column(Text())
    environments = Column(String(500))
    url = Column(String(100))
    lagou_id = Column(Integer())


class Job(Base, Model):
    # 表名
    __tablename__ = 'lagou_job'
    # 表结构
    id = Column(Integer(), primary_key=True)
    company = Column(Integer())
    name = Column(String(100))
    salary_low = Column(Integer())
    salary_high = Column(Integer())
    experience = Column(String(20))
    education = Column(String(20))
    area = Column(String(20))
    city = Column(String(20))
    shortcut = Column(String(100))
    url = Column(String(100))
    tags = Column(String(100))
    publish_time = Column(DateTime())
    description = Column(Text())
    address = Column(String(100))
    lagou_id = Column(Integer())


class ProxyIp(Base, Model):
    # 表名
    __tablename__ = 'proxy_ip'
    # 表结构
    id = Column(Integer(), primary_key=True)
    addr = Column(String(20))
    port = Column(String(10))
    type = Column(String(5))
